import Modal from './modal'
import Icon from './icon'
import Popup from './popup'
import { VueConstructor } from 'vue'

interface Install {
  (vue:VueConstructor): void
  installed?: boolean
}

const install:Install = function (Vue) {
  if (install.installed) return

  install.installed = true
  const components = [
    Modal,
    Icon,
    Popup
  ]
  components.forEach(component => {
    component.install(Vue)
  })
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install
}
